

<template>
  <div class="car-detial"  v-loading="loading">
    <div class="car-info-panel">
			<div class="car-info-title">销售信息</div>
			<el-form :inline="true"  label-width="120px" class="clearfix">
				<el-col :sm="24" :md="12" :lg="8" :xl="6" >
					<el-form-item label="销售类型：">
            {{res.orderSaleType | filterSaleType}}
					</el-form-item>
				</el-col>
				<el-col :sm="24" :md="12" :lg="8" :xl="6" >
					<el-form-item label="成交日期：">
            {{res.orderDealDate | filterDateForDay}}
          </el-form-item>
				</el-col>
				<el-col :sm="24" :md="12" :lg="8" :xl="6" >
					<el-form-item label="销售员工：">
            {{res.user ? res.user.userName : '--'}}
					</el-form-item>
				</el-col>
				<el-col :sm="24" :md="12" :lg="8" :xl="6" >
					<el-form-item label="成交价格：">
            {{res.orderPrice || '--'}} 万
					</el-form-item>
				</el-col>
        <el-col :sm="24" :md="12" :lg="8" :xl="6" >
          <el-form-item label="定金：">
            {{res.orderDeposit || '--'}}
          </el-form-item>
        </el-col>
				<el-col :sm="24" :md="24" :lg="24" :xl="24" >
					<el-form-item label="备注：">
            {{res.orderRemark || '--'}}
					</el-form-item>
				</el-col>
			</el-form>
		</div>
    
    <div class="car-info-panel">
			<div class="car-info-title">客户来源</div>
			<el-form :inline="true"  label-width="120px" class="clearfix">
        <el-col :sm="24" :md="12" :lg="8" :xl="6" >
					<el-form-item label="联系电话：">
            {{res.orderBuyerMobile || '--'}}
					</el-form-item>
				</el-col>
        <el-col :sm="24" :md="12" :lg="8" :xl="6" >
					<el-form-item label="客户名称：">
            {{res.orderBuyerName || '--'}}
					</el-form-item>
				</el-col>
				<el-col :sm="24" :md="12" :lg="8" :xl="6" >
					<el-form-item label="客户来源：">
            {{channelName || '--'}}
					</el-form-item>
				</el-col>
				<el-col :sm="24" :md="12" :lg="8" :xl="6" >
					<el-form-item label="归属地：">
            {{res.city? res.city.cityName : '--'}} {{res.province ? res.province.provinceName : '--'}}
          </el-form-item>
				</el-col>
				<el-col :sm="24" :md="12" :lg="8" :xl="6" >
					<el-form-item label="证件号：">
            {{res.orderBuyerCardNo || '--'}}
					</el-form-item>
				</el-col>
			</el-form>
		</div>
    <div class="car-info-panel">
			<div class="car-info-title">是否代办保险</div>
			<el-form :inline="true"  label-width="120px" class="clearfix">
				<el-col :sm="24" :md="12" :lg="8" :xl="6" >
					<el-form-item label="是否代办保险：">
            {{res.orderInsuranceState | filterSaleInsuranceState}}
					</el-form-item>
				</el-col>				
        <div v-if="res.orderInsuranceState">
          <el-col :sm="24" :md="12" :lg="8" :xl="6" >
            <el-form-item label="保险公司：">
              {{res.orderInsuranceCompany || '--'}}
            </el-form-item>
          </el-col>
          <el-col :sm="24" :md="12" :lg="8" :xl="6" >
            <el-form-item label="商业险：">
              {{res.orderBusinessInsurPrice || '--'}}
            </el-form-item>
          </el-col>
          <el-col :sm="24" :md="12" :lg="8" :xl="6" >
            <el-form-item label="交强险：">
              {{res.orderForceInsurPrice || '--'}}
            </el-form-item>
          </el-col>
        </div>
			</el-form>
		</div>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        loading: false,
        res: {},
        channelName: ''
      }
    },

    methods: {
      getOrderDetial () {
        let getOrder = () => {
          return this.$axios.get(this.$api.getCarOrderList, {params: {carId: this.$route.params.id}})
        }

        let getChannel = () => {
          return this.$axios.get(this.$api.channelList, {params: {marketId: this.$sess.get('userInfo').marketId, shopId: this.$sess.get('userInfo').shopId || '', channelState: 1}})
        }

        let getInsurer = () => {
          return this.$axios.get(this.$api.getInsurerList)
        }
        
        this.$axios.all([getOrder (), getChannel (), getInsurer()]).then(axios.spread((res, channel, insurer) => {
          this.res = res.data.result[0]
          let channelList = channel.data.result
          this.channelName = channelList.filter(item => item.channelId == this.res.channelId)
          this.channelName = this.channelName.length > 0 ? this.channelName[0].channelName : '--'
          
          let insurerList = insurer.data.result
          let insurerI = insurerList.filter(item => item.insuranceId == this.res.orderInsuranceCompany)
          this.res.orderInsuranceCompany = insurerI.length > 0 ? insurerI[0].insuranceName : '--'
        }))
      }
    },

    activated () {
      this.getOrderDetial()
    }
  }

</script>

<style scoped>
.el-form-item{
  margin-bottom: 0;
}
</style>
